package com.xiao.xin.core.controller;

import com.xiao.xin.core.dto.Result;
import com.xiao.xin.core.dto.UserLoginDto;
import com.xiao.xin.core.service.UserService;
import com.xiao.xin.core.vo.UserLoginResponseVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/1.0/user")
public class UserController {

    private final UserService userService;

    /***
     * 用户登录
     * @param dto
     * @return
     */
    @PostMapping("/login")
    public Result<UserLoginResponseVo> login(@RequestBody UserLoginDto dto) {
        log.info("用户登录:{}", dto);
        return Result.success(userService.login(dto));
    }
}
